package acwing._2LanQiao._3Math_DP;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @Project : ProgrammingExercises
 * @Package : ACWing._2LanQiao._3Math_DP
 * @File : Q1214.java
 * @Author : WangRuoyu
 * @Date : 2023/3/15 11:19
 */

public class Q1214 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] words = br.readLine().split(" ");

        int n = Integer.parseInt(words[0]);
        int s = Integer.parseInt(words[1]);
        int a = Integer.parseInt(words[2]);
        int b = Integer.parseInt(words[3]);

        final int MOD = 100000007;
        final int SMODN;
        if (s < 0) {
            SMODN = n + (s % n);
        } else {
            SMODN = s % n;
        }

        int[][] f = new int[n][n];

        f[1][a % n] = 1;
        f[1][(n * b - b) % n] = 1;

        for (int i = 1; i <= n - 1; ++i) {
            for (int j = 0; j < n; ++j) {
                f[i][j] = (f[i][j] + f[i - 1][(n * a + j - i * a) % n]) % MOD;
                f[i][j] = (f[i][j] + f[i - 1][(j + i * b) % n]) % MOD;
            }
        }
        System.out.println(f[n - 1][SMODN]);
    }
}
